﻿using UnityEngine;
using System.Collections;

public class ColorPress : MonoBehaviour {

	public ColorPanelChange cPC;
	public string ColorToCode;
	public PuzzleRoomManager puzzleRoomManager;
	public CameraManager cameraManager;

	// Use this for initialization
	void Start () {
		cPC = GameObject.Find("ColorPanelString").GetComponent<ColorPanelChange>();
		puzzleRoomManager = GameObject.Find("PuzzleRoomManager").GetComponent<PuzzleRoomManager>();
		cameraManager = GameObject.Find(this.name).GetComponent<CameraManager>();
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetMouseButtonDown(0))
			if(puzzleRoomManager.puzzleRoomData.Mouse.collider2D.bounds.Intersects(this.collider2D.bounds))
				keyPressed ();
	}

	void keyPressed()
	{
		GameObject.Find("MenuManager").GetComponent<MusicManager>().PlaySoundEffect(Resources.Load("SFX/clk4_2", typeof(AudioClip)) as AudioClip);
		if(ColorToCode != null)
			cPC.Addsterisk(ColorToCode);
		else
		{
			puzzleRoomManager.mouseActive = false;
			cameraManager.changeCamera(cameraManager.setCamInd);
		}
	}
}
